function load() {
    givenButton();
    init();
}
function givenButton() {
    var btn = document.getElementById("selectNum");
    var data = [32, 11, 34, 26, 22];
    for (var i = 0; i < data.length; i++) {
        var button = buttonCreate(data[i]);
        btn.appendChild(button);
        button.onclick = function () {
            deleteButton(this);
        };
    }
}
function init() {
    var lIn = document.getElementById("left_in");
    lIn.onclick = function () {
        leftIn();
    }
    var rIn = document.getElementById("right_in");
    rIn.onclick = function () {
        rightIn();
    }
    var lOut = document.getElementById("left_out");
    lOut.onclick = function () {
        var lo=leftOut();
        alert(lo);
    }
    var rOut = document.getElementById("right_out");
    rOut.onclick = function () {
        var ro=rightOut();
        alert(ro);
    }
}
function buttonCreate(data) {
    var button = document.createElement("button");
    button.style.borderStyle = "none";
    button.style.backgroundColor = "red";
    button.style.width = 4 + "%";
    button.style.height = 4 + "%";
    button.style.marginRight = 10 + "px";
    button.style.marginTop = 5 + "px";
    button.style.color = "white";
    var node = document.createTextNode(data);
    button.appendChild(node);
     button.onclick = function () {
            deleteButton(this);
        };
    return button;
}
function deleteButton(button) {
    var parentDiv = document.getElementById("selectNum");
    parentDiv.removeChild(button);
}
function leftIn() {
    var input = document.getElementById("input").value;
    if(input==""){return;}
    var btn = document.getElementById("selectNum");
    var button = buttonCreate(input);
    var btnB = btn.children[0];
    btn.insertBefore(button, btnB);

}
function rightIn() {
   var input = document.getElementById("input").value;
   if(input==""){return;}
    var btn = document.getElementById("selectNum");
    var button = buttonCreate(input);
    btn.appendChild(button);
}
function leftOut() {
    var btn = document.getElementById("selectNum");
    del=btn.children[0];
    btn.removeChild(del);
    return btn.children.length; 
}
function rightOut() {
    var btn = document.getElementById("selectNum");
    var len=btn.children.length;
    del=btn.children[len-1];
    btn.removeChild(del); 
    return btn.children.length; 
}